﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GeoSketch2.Archaeo
{
    /// <summary>
    /// The form to enter information about the soil, park canada template
    /// </summary>
    public partial class SoilSheetFormParksCanada : Form
    {
        #region Fields
        SoilSheetParksCanada SoilSheet; 
        #endregion

        #region Constructor
        /// <summary>
        /// The form to enter information about the soil, park canada template
        /// </summary>
        /// <param name="SoilSheet">The object which will contain the datas about the soil</param>
        public SoilSheetFormParksCanada(SoilSheetParksCanada SoilSheet)
        {
            InitializeComponent();

            this.SoilSheet = SoilSheet;

            LoadSheet();
        } 
        #endregion

        #region Events
        private void Button_OK_Click(object sender, EventArgs e)
        {
            SaveSheet();
            this.Close();
        }

        private void Button_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        } 
        #endregion

        #region Methods
        void LoadSheet()
        {
            Label_ArchaeologistName.Text += SoilSheet.Area.ArchaeologistName;
            Label_Date.Text += SoilSheet.Area.CreationTime.ToLongDateString();

            foreach (Benchmark bm in SoilSheet.Area.Project.SiteBenchmarks)
            {
                if (!bm.Reference)
                {
                    if (bm.ExcavationArea == SoilSheet.Area)
                    {
                        DataGridBenchmarks.Rows.Add(new object[]{
                        bm.Name,
                        bm.Altitude.ToString(Core.Vars.Setup.GeoSketch.NumberFormat)
                        });
                    }
                }
            }

            TextBox_SoilDescription.Text = SoilSheet.SoilDescription;
            TextBox_Artefacts.Text = SoilSheet.Artefacts;
            TextBox_Interpretation.Text = SoilSheet.Interpretation;
            TextBox_EndWhy.Text = SoilSheet.EndWhy;
        }

        void SaveSheet()
        {
            SoilSheet.SoilDescription = TextBox_SoilDescription.Text;
            SoilSheet.Artefacts = TextBox_Artefacts.Text;
            SoilSheet.Interpretation = TextBox_Interpretation.Text;
            SoilSheet.EndWhy = TextBox_EndWhy.Text;
        } 
        #endregion
    }
}
